package com.iocharger.demo.dto;

import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    private Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static <T> Result<?> success(){
        return new Result<>(0,"success",null);
    }
    public static <T> Result<?> success(T data){
        return new Result<>(0,"success",data);
    };
    public static <T> Result<?> fail(String msg){
        return new Result<>(-1, msg,null);
    }
    public static <T> Result<?> fail(int code, String msg){
        return new Result<>(code, msg,null);
    }
}